<template>
	<view>
		<common-list  v-for="(item,index) in list" :key="index"
		:item="item" :index="index"></common-list>
		<no-thing v-if="list.length === 0"></no-thing>
	</view>
</template>

<script>
	import commonList from '@/components/common/common-list.vue';
	import noThing from '@/components/common/no-thing.vue';
	export default {
		components: {
			commonList,
			noThing
		},
		data() {
			return {
				list:[]
			}
		},
		onUnload() {
		},
		onLoad() {
			// 取出历史记录
			let list = uni.getStorageSync('history')
			if(list){
				this.list = JSON.parse(list)
				
			}
	
		},
		onNavigationBarButtonTap() {
			uni.showModal({
				content: '是否要清除历史记录？',
				success: (res)=>{
					if (res.confirm) {
						uni.removeStorageSync('history')
						this.list = []
					}
				}
			});
		},
	}
</script>

<style>

</style>
